<template>
  <div class="returnList">
    <el-card class="searchBar" shadow="never">
      <div class="searchBar-title">查询条件</div>
      <el-form
        ref="form"
        :inline="true"
        :model="searchForm"
        class="demo-form-inline"
        size="small"
      >
        <el-form-item label="订单编号">
          <el-input v-model="searchForm.orderSn" placeholder="请填写订单编号" />
        </el-form-item>
        <el-form-item label="退单状态">
          <el-select
            v-model="searchForm.status"
            clearable
            placeholder="退单状态"
          >
            <el-option label="待处理" value="0" />
            <el-option label="退货中" value="1" />
            <el-option label="已完成" value="2" />
            <el-option label="已拒绝" value="3" />
          </el-select>
        </el-form-item>
        <div class="searchBar-btn">
          <el-form-item>
            <el-button size="mini" type="primary" @click="onSearch"
              >查询</el-button
            >
          </el-form-item>
          <el-form-item>
            <el-button size="mini" @click="onReset">重置</el-button>
          </el-form-item>
        </div>
      </el-form>
    </el-card>
    <el-card class="formTable">
      <el-table :data="tableData" style="width: 100%" border>
        <el-table-column label="#" fixed type="index" align="center" />
        <el-table-column
          label="订单序号"
          width="300px"
          prop="orderSn"
          align="center"
        />
        <el-table-column label="订单状态" align="center" width="150px">
          <template slot-scope="scope">
            <el-button v-if="scope.row.status == 0" type="danger" size="mini">
              待处理
            </el-button>
            <el-button
              v-else-if="scope.row.status == 1"
              type="warning"
              size="mini"
            >
              退货中
            </el-button>
            <el-button
              v-else-if="scope.row.status == 2"
              type="primary"
              plain
              size="mini"
            >
              已完成
            </el-button>
            <el-button
              v-else-if="scope.row.status == 3"
              type="info"
              size="mini"
            >
              已拒绝
            </el-button>
          </template>
        </el-table-column>
        <el-table-column
          label="描述"
          prop="description"
          align="center"
          width="200px"
        />
        <el-table-column
          label="退单原因"
          prop="reason"
          align="center"
          width="200px"
        />
        <el-table-column
          label="商品名称"
          prop="productName"
          align="center"
          width="200px"
        />
        <el-table-column
          label="商家备注"
          prop="handleNote"
          align="center"
          width="200px"
        />
        <el-table-column
          label="添加时间"
          prop="createTime"
          align="center"
          width="200px"
        />
        <el-table-column
          fixed="right"
          label="操作"
          align="center"
          width="140px"
        >
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="primary"
              icon=" el-icon-view"
              @click="handleEdit(scope.row.id)"
              >查看订单</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页 -->
      <div class="main-footer">
        <el-pagination
          :current-page="page.currentPage"
          :page-sizes="page.pageSizes"
          :page-size="page.pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="page.total"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
        />
      </div>
    </el-card>
  </div>
</template>

<script>
import { findReturnApply } from '@/api/orders/returnList/index'
import mixins from '@/mixins/index'
export default {
  mixins: [mixins],
  data() {
    return {
      searchForm: {},
      tableData: []
    }
  },
  created() {
    this.init()
  },
  mounted() {},
  methods: {
    init() {
      findReturnApply(
        this.page.currentPage,
        this.page.pageSize,
        this.searchForm
      ).then((res) => {
        console.log(res)
        this.tableData = res.data.rows
        this.page.total = res.data.total
      })
    },
    // 搜索
    onSearch() {
      // productList
      this.page.currentPage = 1
      this.init()
    },
    // 重置搜索框
    onReset() {
      this.searchForm = this.$options.data().searchForm
      this.onSearch()
    },
    // 查看订单详情
    handleEdit(id) {
      this.$router.push({ path: `returnDetail/${id}` })
    }
  }
}
</script>

<style lang="scss" scoped>
.orderList {
  .searchBar {
    .demo-form-inline {
      margin: 20px 20px 0;
      flex-wrap: wrap;
      .el-form-item {
        margin: 10px 20px 0;
      }
    }
  }
  .formTable {
    .payBtn {
      padding: 0 10px;
      // width: ;
      .svg-icon {
        font-size: 25px;
      }
    }
    .noPay {
      padding: 10px;
    }
  }
}
</style>

